﻿#include "ssObject.h"
#include "reflection/ssClassFactory.h"

namespace StarSeeker
{

ssObject::ssObject()
{
}

ssObject::ssObject(const char* name) :m_className(name)
{
}

ssObject::~ssObject()
{
}

size_t ssObject::GetFiledCount()
{
	return ssSingle<ssClassFactory>::instance()->GetFieldCount(m_className);
}

StarSeeker::ssClassFeild* ssObject::GetFeild(size_t pos)
{
	return ssSingle<ssClassFactory>::instance()->GetFeild(m_className, pos);
}

StarSeeker::ssClassFeild* ssObject::GetFeild(const std::string& feildName)
{
	return ssSingle<ssClassFactory>::instance()->GetFeild(m_className, feildName);
}

void ssObject::Set(const std::string& feildName, const char* value)
{
	ssClassFeild* feild = ssSingle<ssClassFactory>::instance()->GetFeild(m_className, feildName);
	*((std::string*)((unsigned char *)(this) + feild->Offset())) = std::string(value);
}

}
